import {getCate,getBanner,gethortGoods} from "../../request/api"
const state = {
    //首页导航
    cate: [],
    //轮播图
    banner: [],
    //底部商品
    goods:[]
}
const mutations = {
    changeCate(state, val) {
        state.cate = val
    },
    changeBanner(state, val) {
        state.banner = val
    },
    changeGoods(state, val) {
        state.goods = val
    }
}
const actions = {
    asyncChangeCate(context) {
        getCate().then(res => {
            context.commit("changeCate",res.data.list)
        })
    },
    asyncChangeBanner(context) {
        getBanner().then(res => {
            context.commit("changeBanner",res.data.list)
        })
    },
    asyncChangeGoods(context) {
        gethortGoods().then(res => {
            context.commit("changeGoods",res.data.list)
        })
    }
}
const getters = {
    cate(state) {
        return state.cate
    },
    banner(state) {
        return state.banner
    },
    goods(state) {
        return state.goods
    }
}

export default {
    state, mutations, actions, getters,
    namespaced:true
}